<%@ page import="java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ include file="loginDetails.jsp" %>

<%!
boolean createUser(JspWriter out,HttpServletRequest request,
					HttpSession session)
{
	Connection con = null;
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	String level_of_access = request.getParameter("level_of_access");
	try{
		con = DriverManager.getConnection(url, user_id, pass); 
		Statement stmt = con.createStatement();
		String sql = "INSERT INTO users VALUES ('" + username + "', '" + password + "'," + level_of_access + ");";
		stmt.executeUpdate(sql);
	}
	catch(Exception e){
		return false;
	}
	
	return true;
} 
%>

<%
boolean created;
created = createUser(out,request,session);

if(created)
	response.sendRedirect("http://www.google.com");
else
	response.sendRedirect("http://www.yahoo.com"); 
%>